<%@page import="itpenguin.common.Util"%>
<%@page import="itpenguin.entities.Series"%>
<%@page import="itpenguin.entities.Article"%>
<%@page import="java.util.List"%>
<%@page import="javax.jdo.Query"%>
<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<nav class="seriese_nav">
	<h1><a href="/${series.contextName}/${series.id}">${series.title}</a></h1>
	<section>${series.description}</section>
	<ul>
		<c:set var="currentSr" value="${series}" />
		<%
		Series currentSr = (Series)request.getAttribute("series");
		List<Series> results = Util.GetChildSheries(currentSr.getId());
		pageContext.setAttribute("seriesList", results);
		pageContext.setAttribute("hasChild", results.size() != 0);
		%>
		<c:if test="${hasChild}">
			<c:forEach var="child" items="${seriesList}">
				<c:set var="series" value="${child}" scope="request"/>
				<li>
					<jsp:include page="series.jsp" />
				</li>
			</c:forEach>
		</c:if>
		<c:if test="${!hasChild}">
			<%
			pageContext.setAttribute("articleList", Util.GetSeriesList(currentSr.getId()));
			%>
			<c:forEach var="article" items="${articleList}">
				<li>
					<a href="/${article.contextName}/${article.id}">#${article.partNumber} ${article.title}</a>
					<fmt:formatDate var="utcDt" value="${article.published}" pattern="yyyy-MM-dd'T'HH:mm:ss" timeZone="UTC"/>
					<time datetime="${utcDt}"><fmt:formatDate value="${article.published}" pattern="yyyy/MM/dd"/></time>
				</li>
			</c:forEach>
		</c:if>
	</ul>
</nav>
   